package StudyCode.summary.Basic.numberformat;

import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Locale;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class NumberFormatLocale {
	public static void displayNumber(Locale currentLocale) {
		Integer quantity = 123456;
		Double amount = 345987.246;
		NumberFormat numberFormatter;
		String quantityOut;
		String amountOut;

		numberFormatter = NumberFormat.getNumberInstance(currentLocale);
		quantityOut = numberFormatter.format(quantity);
		amountOut = numberFormatter.format(amount);
		System.out.println(quantityOut + "   " + currentLocale.toString());
		System.out.println(amountOut + "   " + currentLocale.toString());
	}


	public static void main(String[] args) {
		ArrayList<Locale> locales = new ArrayList<>();
		locales.add(0, new Locale.Builder().setLanguage("zh").setRegion("CN").build());
		locales.add(1, new Locale.Builder().setLanguage("de").setRegion("DE").build());
		for (Locale locale : locales) {
			displayNumber(locale);
		}

	}
}